{% extends "layouts" ~ DIR ~ "default.twig" %}

{% block title %}{{ "Manage Users" | translate }}{% endblock %}

{% block content %}
<form class="filters" action="{{ url('manage_users') }}" method="post" accept-charset="UTF-8" role="search">
<fieldset role="presentation">
<label for="query">
{{ "Search&hellip;" | translate }}
<a href="{{ url('help/id/filtering_results') }}" rel="help" target="_blank" class="help emblem">
{{- icon_svg("help.svg", "Help" | translate) -}}
</a>
</label>
<input class="text filter_text" type="text" name="query" value="{{ GET.query | fix(true, true) }}" id="query">
<button type="submit">{{ "Search" | translate }}</button>
{% if visitor.group.can("add_user") %}
<a href="{{ url('new_user') }}" class="button yay">
{{ icon_svg("add.svg") }}{{ "New User" | translate }}
</a>
{% endif %}
</fieldset>
</form>
<h2>{{ GET.query is not empty ? "Search Results" | translate : "Users" | translate }}</h2>
<table>
<thead>
<tr class="head">
<th class="user_name name main">{{ "Login (name)" | translate }}</th>
<th class="user_group value">{{ "Group" | translate }}</th>
<th class="user_joined date">{{ "Joined" | translate }}</th>
<th class="user_website name">{{ "Website" | translate }}</th>
{% if site.email_activation %}
<th class="user_activated emblem" title="approved">{{ "Activated?" | translate }}</th>
{% endif %}
{{ trigger.call("manage_users_column_header") }}
<th class="controls" colspan="2">{{ "Controls" | translate }}</th>
</tr>
</thead>
<tbody>
{% for user in users.paginated %}
<tr id="user_{{ user.id }}" class="user">
<td class="user_name name main">
<a href="mailto:{{ user.email | fix(true) }}">{{ user.login | fix(false, true) }}</a>
{% if user.full_name is not empty %}<span class="sub">({{ user.full_name | fix(false, true) }})</span>{% endif %}
</td>
<td class="user_group value">
<a href="{{ url('manage_groups/search/' ~ (user.login | url_encode)) }}">{{ user.group.name | fix(false, true) }}</a>
</td>
<td class="user_joined date">
{{ user.joined_at | time }}
</td>
<td class="user_website name">
{% if user.website is not empty %}<a href="{{ user.website | fix(true) }}">{{ user.website | fix(false, true) }}</a>{% endif %}
</td>
{% if site.email_activation %}
<td class="user_activated emblem">
{% if user.approved %}
{{ icon_svg("success.svg", "Yes" | translate, "emblem") }}
{% endif %}
</td>
{% endif %}
{{ trigger.call("manage_users_column", user) }}
<td class="controls">
{%- if visitor.group.can("edit_user") -%}
{{ user.edit_link(icon_svg("edit.svg", "Edit" | translate), null, null, "emblem") }}
{%- else -%}
{{ icon_svg("forbidden.svg", false, "emblem forbidden") }}
{%- endif -%}
</td>
<td class="controls">
{%- if visitor.group.can("delete_user") -%}
{{ user.delete_link(icon_svg("delete.svg", "Delete" | translate), null, null, "emblem") }}
{%- else -%}
{{ icon_svg("forbidden.svg", false, "emblem forbidden") }}
{%- endif -%}
</td>
</tr>
{% else %}
<tr>
<td class="placeholder">
{{ icon_svg("failure.svg", false, "emblem") }}
{{ "No results" | translate }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% if users.paginated is not empty and users.pages > 1 %}
<div class="pagination">
<span class="pages">{{ "Page %d of %s" | translate | format(users.page, users.final_link(users.pages)) }}</span>
{{ users.prev_link }}
{{ users.next_link }}
</div>
{% endif %}
{% endblock %}
